﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PCLawPrototype
{
    public partial class PUContactFrm : Form
    {
        List<Contact> contacts = new List<Contact>();
        private EditForm _caller;

        public PUContactFrm(EditForm parent)
        {
            InitializeComponent();

            _caller = parent;
            FillToGrid();
        }

        private void FillToGrid()
        {
            contacts = Common.Entity.Contacts.ToList();

            foreach (Contact contact in contacts)
            {
                ListViewItem listViewItem1 = new ListViewItem(new string[] {
                contact.ContactFirstName + " " + contact.ContactMiddleName + " " + contact.ContactLastName,
                contact.ContactPosition,
                contact.ContactState,
                contact.ContactCountry,
                contact.ContactEmail1 ?? contact.ContactEmail2}, -1);

                this.lstClient.Items.Add(listViewItem1);

            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            _caller.ManagedContact = contacts[lstClient.SelectedIndices[0]];
            this.Close();
        }
    }
}
